<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="js/jquery.min.js" type="text/javascript"></script>
<link href="css/zhu/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<link href="css/zhu/memberrole.css" rel="stylesheet">
<link href="css/zhu/Administrators.css" rel="stylesheet">
<script type="text/javascript">
	$(function() {

		//删除按钮
		$(".deletebtn").click(function() {
			var carinfo_id = $(this).attr("carinfoid");
			alert("删除成功！");
			location.href = "/fuhe/deletecar?carinfo_id=" + carinfo_id;
		})

		//提交事件
		$(".sendbtn").click(function() {
			var id = $(this).prev().val();
			location.href = "/fuhe/updatecar?carinfo_id=" + id;
		})

		$(".shangchuan").click(function() {
			alert(333);
			//获取表单数据
			var formData = new FormData($(this).parent()[0]);
			//获取carinfo_id
			var carinfo_id = $(this).next().val();
			console.log(formData);
			alert(carinfo_id);
		})
	})
</script>
</head>
<body>
	<c:set var="isDoing" value="0" />
	<c:forEach items="${powerList}" var="power" varStatus="status">

		<c:if test="${power.name=='车辆管理' && isDoing==0}" var="u">
			<!--  设置跳出 条件 -->
			<c:set var="isDoing" value="1" />
			<div class="zuida">
				<!-- 头部 -->
				<div class="zuishangdiv">
					<h3 style="color: #337ab7">
						<c:if test="${admin.role_id != 1 }">
							${store.name }车辆列表
						</c:if>
					</h3>
				</div>
				<div class="zhongjiandiv">
					<ul>
						<li><select name="brand">
								<option value="">所有品牌</option>
								<c:forEach items="${brandFromStore}" var="brand">
									<option value="${brand.id}">${brand.name}</option>
								</c:forEach>
						</select>
							<button type="button" class="addbtn btn btn-primary" data-toggle="modal"
								data-target="#add${carinfo.id}">添加</button></li>
					</ul>
				</div>
				<!-- 车辆列表 -->
				<div>
					<table width="100%" border="0" cellspacing="0" cellpadding="0"
						class="tablelist table table-striped table-bordered table-hover  table-condensed"
						id="myTable">
						<thead>
							<th width="10%">车名</th>
							<th width="6%">车牌</th>
							<th width="6%">品牌</th>
							<th width="9%">上</th>
							<th width="9%">下</th>
							<th width="9%">左</th>
							<th width="9%">右</th>
							<th width="9%">前</th>
							<th width="9%">后</th>
							<th width="9%">内</th>
							<th width="8%">状态</th>
							<th width="10%">操作</th>
						</thead>
						<tbody>
							<c:forEach items="${carInfoList}" var="carinfo">
								<tr>
									<td style="vertical-align: middle;">${carinfo.name}</td>
									<td style="vertical-align: middle;">${carinfo.cardnumber}</td>
									<td style="vertical-align: middle;">${carinfo.brand_name }</td>
									<td><img style="width: 100px; height: 100px"
										src="${carinfo.top_img}"></td>
									<td><img style="width: 100px; height: 100px"
										src="${carinfo.bottom_img}"></td>
									<td><img style="width: 100px; height: 100px"
										src="${carinfo.left_img}"></td>
									<td><img style="width: 100px; height: 100px"
										src="${carinfo.right_img}"></td>
									<td><img style="width: 100px; height: 100px"
										src="${carinfo.front_img}"></td>
									<td><img style="width: 100px; height: 100px"
										src="${carinfo.back_img}"></td>
									<td><img style="width: 100px; height: 100px"
										src="${carinfo.in_img}"></td>
									<td style="vertical-align: middle;"><c:if
											test="${carinfo.status == 0 }" var="i">
											未出租
										</c:if> <c:if test="${!i }">
											已出租
										</c:if></td>
									<td style="vertical-align: middle;">
										<button type="button" class="btn btn-primary"
											data-toggle="modal" data-target="#update${carinfo.id}">修改</button>
										<div class="modal fade" id="update${carinfo.id}" tabindex="-1"
											role="dialog" aria-labelledby="myModalLabel">
											<div class="modal-dialog">
												<div class="modal-content">
													<div class="modal-header">
														<button data-dismiss="modal" class="close" type="button">
															<span aria-hidden="true">×</span><span class="sr-only">Close</span>
														</button>
														<h4 class="modal-title">修改车辆信息</h4>
													</div>
													<div class="modal-body">
														<table border="0" cellspacing="0" cellpadding="0">
															<tbody>
																<tr>
																	<td>车名:</td>
																	<td><input name="carname" type="text"
																		value="${carinfo.name }" disabled="true"></td>
																</tr>
																<tr>
																	<td>车牌：</td>
																	<td><input name="cardnumber" type="text"
																		value="${carinfo.cardnumber}" disabled="true" /></td>
																</tr>
																<tr>
																	<td>品牌：</td>
																	<td><input name="brand" type="text"
																		value="${carinfo.brand_name}" disabled="true" /></td>
																</tr>
																<form action="/fuhe/duofileservlet" method="post"
																	enctype="multipart/form-data">
																	<tr>
																		<td>上：</td>
																		<td><input type="file" name="f"></td>
																	</tr>
																	<tr>
																		<td>下：</td>
																		<td><input type="file" name="f"></td>
																	</tr>
																	<tr>
																		<td>左：</td>
																		<td><input type="file" name="f"></td>
																	</tr>
																	<tr>
																		<td>右：</td>
																		<td><input type="file" name="f"></td>
																	</tr>
																	<tr>
																		<td>前：</td>
																		<td><input type="file" name="f"></td>
																	</tr>
																	<tr>
																		<td>后：</td>
																		<td><input type="file" name="f"></td>
																	</tr>
																	<tr>
																		<td>内：</td>
																		<td><input type="file" name="f"> <input
																			type="hidden" name="carinfo_id" value="${carinfo.id}">
																			<input type="submit" value="提交"></td>
																	</tr>
																</form>
																<!-- <tr>
																		<td>
																		
																		<input  type="submit" value="上传"></td>
																		<input class="shangchuan" type="button" value="上传">
																	</tr> -->
															</tbody>
														</table>
													</div>
													<div class="modal-footer">
														<!-- <button data-dismiss="modal" class="btn btn-default"
															type="button">关闭</button> -->
														<!-- <input class="btn btn-primary sendbtn" type="button" value="提交"> -->

													</div>
												</div>
												<!-- /.modal-content -->
											</div>
											<!-- /.modal-dialog -->
										</div>


										<button carinfoid="${carinfo.id}" type="button"
											class="deletebtn btn btn-danger">删除</button>
									</td>
									<td style="display: none">${ad.id}</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
		</c:if>
		<c:if test="${fn:length(powerList) == status.count && isDoing==0 }">
			<c:if test="${!u }">
				<jsp:include page="403.jsp"></jsp:include>
			</c:if>
		</c:if>
	</c:forEach>
</body>

</html>